

'use strict';
exports.main = async (event, context) => {
  const appid = 'wxfc2c37f898379a79';
  const secret = '2c5ad4478900f0d8343711f8b6c5f9cf';
  const apiUrl = `https://api.weixin.qq.com/sns/jscode2session?appid=${appid}&secret=${secret}&js_code=${event.code}&grant_type=authorization_code`;
  const res = await uniCloud.httpclient.request(apiUrl, {
    dataType: 'json'
  });
  return res.data.openid;
};